<%--
  Created by IntelliJ IDEA.
  User: hysio
  Date: 2020/5/10
  Time: 16:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>软件测试工程师管理系统 - 选择工程师</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <style>
        .layui-table-box {
            overflow: visible;
        }

        .layui-table-body {
            overflow: visible;
        }

        td .layui-form-select {
            padding: 0 0px 0px;
        }
    </style>
</head>
<body class="layui-layout-body">

<%
    if(session.getAttribute("user") == null)
    {
        response.sendRedirect("login.jsp");
    }
%>

<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">软件测试工程师管理系统</div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <%=session.getAttribute("user")%>
                </a>
            </li>
            <li class="layui-nav-item"><a href="login.jsp">退出</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item"><a href="index.jsp">首页</a></li>
                <li class="layui-nav-item"><a href="insert.jsp">添加工程师</a></li>
                <li class="layui-nav-item"><a href="select.jsp">查询工程师</a></li>
                <li class="layui-nav-item"><a href="select.jsp">修改工程师</a></li>
                <li class="layui-nav-item"><a href="select.jsp">删除工程师</a></li>
                <li class="layui-nav-item"><a href="history.jsp">操作记录</a></li>
                <li class="layui-nav-item"><a href="calculate.jsp">薪水计算</a></li>
                <li class="layui-nav-item"><a href="sort.jsp">资料排序</a></li>
                <li class="layui-nav-item"><a href="empty.jsp">清空资料</a></li>
                <li class="layui-nav-item"><a href="print.jsp">打印报表</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="layui-tab-item layui-show">
            <div class="layui-main">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>查询工程师</legend>
                </fieldset>
                <form class="layui-form layui-form-pane" action="">

                    <table class="layui-hide" id="test" lay-filter="test"></table>

                </form>
            </div>
        </div>
    </div>

</div>

<script src="layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['table', 'laydate', 'form'], function(){
        var table = layui.table;
        var laydate = layui.laydate
        var form = layui.form;

        table.render({
            elem: '#test'
            ,url:'/idea_project_war_exploded/Result'
            ,toolbar: false
            ,title: '用户数据表'
            ,totalRow: true
            ,cols: [[
                {field:'id', title:'ID', width:80, fixed: 'left'}
                ,{field:'name', title:'姓名', width:120}
                ,{field:'sex', title:'性别', width:80}
                ,{field:'birth', title:'生日', width:120}
                ,{field:'degree', title:'学历', width:80}
                ,{field:'origin', title:'籍贯', width:120}
                ,{field:'address', title:'地址'}
                ,{field:'tel', title:'联系方式', width:160}
                ,{field:'wyear', title:'工龄', width:80}
                ,{field:'wage', title:'工资', width:120}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:120}
            ]]
            ,page: false
            ,response: {
                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
            }
            ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.status, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.total, //解析数据长度
                    "data": res.rows.item //解析数据列表
                };
            }
        });

        var $ = layui.$;
        var ELEM_EDIT = 'layui-table-edit';
        //监听行工具事件
        table.on('tool(test)', function(obj) {
            var data = obj.data;
            var that = this;
            var field = $(that).data('field');
            var othis = $(this)

            if (obj.event === 'del') {
                layer.confirm('确认删除？', function (index) {
                    obj.del();
                    layer.close(index);
                    layer.msg('删除成功！');
                    window.open("DeleteByNum?id=" +data.id, '_top');
                });
            } else if (obj.event === 'edit') {
                    window.open("Alter?id=" +data.id + "&name=" +data.name+ "&sex=" + data.sex + "&birth=" + data.birth + "&degree=" +data.degree +
                        "&origin=" + data.origin + "&address=" + data.address+ "&tel=" + data.tel + "&wyear="+ data.wyear + "&wage=" + data.wage, '_top');
            }
            console.log(table.cache)
        });
    });
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
</script>
</body>
</html>